using ZR.Model.Enums;

namespace ZR.Model.BaseFrame.Dto
{
    /// <summary>
    /// 数据字典表单对象
    /// </summary>
    public class DataDicFormDtoBase
    {      
        /// <summary>
        /// 上级字典
        /// </summary>
        [Required(ErrorMessage = "上级字典不能为空")]
        public long PaDataDicId { get; set; }
        
        /// <summary>
        /// 数据字典标识
        /// </summary>
        [Required(ErrorMessage = "数据字典标识不能为空")]
        public long DataDicId { get; set; }
        
        /// <summary>
        /// 数据名
        /// </summary>
        [Required(ErrorMessage = "数据名不能为空")]
        public string DataName { get; set; }
        
        /// <summary>
        /// 数据代码
        /// </summary>
        [Required(ErrorMessage = "数据代码不能为空")]
        public string DataCode { get; set; }
        
        /// <summary>
        /// 排序编号
        /// </summary>
        [Required(ErrorMessage = "排序编号不能为空")]
        public int SortNo { get; set; }
        
        /// <summary>
        /// 备注
        /// </summary>
        public string Remark { get; set; }
        
        /// <summary>
        /// 状态
        /// </summary>
        [Required(ErrorMessage = "状态不能为空")]
        public string StateCode { get; set; }
        

    }

    /// <summary>
    /// 删除数据字典请求对象
    /// </summary>
    public class DeleteDataDicReqBase
    {
        /// <summary>
        /// 标识集合
        /// </summary>
        public string Ids { get; set; }
    }

    /// <summary>
    /// 变更数据字典状态请求对象
    /// </summary>
    public class ChangeDataDicStateReqBase
    {
        /// <summary>
        /// 标识
        /// </summary>
        public long Id { get; set; }
        
        /// <summary>
        /// 状态编码
        /// </summary>
        public string StateCode { get; set; }
        
        /// <summary>
        /// 状态枚举
        /// </summary>
        [JsonIgnore]
        public DataStateEnum? StateEnum
        {
            get
            {
                DataStateEnum stateEnum;
                var isOk = Enum.TryParse(StateCode, true, out stateEnum);
                if (isOk && Enum.IsDefined(stateEnum))
                {
                    return stateEnum;
                }
                return null;
            }
        }
    }

    /// <summary>
    /// 获取数据字典树选择列表请求对象
    /// </summary>
    public class GetDataDicTreeSelectListReqBase:GetTreeSelectListReqBase
    {
    }

    /// <summary>
    /// 获取数据字典分页列表请求对象
    /// </summary>
    public class GetDataDicPageListReqBase : PagerInfo 
    {
        /// <summary>
        /// 树结点标识
        /// </summary>
        public long? TreeNodeId { get; set; }
        /// <summary>
        /// 是否是默认结点类型
        /// </summary>
        public bool IsDefaultNodeType { get; set; }=true;

        /// <summary>
        /// 关键词
        /// </summary>
        public string Keywords { get; set; }

        /// <summary>
        /// 状态
        /// </summary>
        public string StateCode { get; set; }


    }

    /// <summary>
    /// 数据字典列表项
    /// </summary>
    public class DataDicListItemDtoBase
    {
        /// <summary>
        /// 上级字典
        /// </summary>
        public long PaDataDicId { get; set; }
        
        public string PaDataName { get; set; }
        /// <summary>
        /// 数据字典标识
        /// </summary>
        public long DataDicId { get; set; }
        
        /// <summary>
        /// 数据名
        /// </summary>
        public string DataName { get; set; }
        
        /// <summary>
        /// 数据代码
        /// </summary>
        public string DataCode { get; set; }
        
        /// <summary>
        /// 排序编号
        /// </summary>
        public int SortNo { get; set; }
        
        /// <summary>
        /// 备注
        /// </summary>
        public string Remark { get; set; }
        
        /// <summary>
        /// 创建时间
        /// </summary>
        public DateTime? CreateTime { get; set; }
        
        /// <summary>
        /// 创建人
        /// </summary>
        public string Creater { get; set; }
        
        /// <summary>
        /// 状态
        /// </summary>
        public string StateCode { get; set; }
        
    }

    /// <summary>
    /// 数据字典详情
    /// </summary>
    public class DataDicDetailDtoBase: DataDicFormDto
    {

    }
}